/*
 * PublicDefine.cpp

 *
 *  Created on: 2017年5月26日
 *      Author: orange
 */

#include "PublicDefine.h"

#include <stdarg.h>
#include <cstdio>
#include <cstring>

#include "event/LogFileJuzEvent.h"
#include "Plugin.h"

using namespace std;



Plugin* JuzLog::sendPl = NULL;

void JuzLog::Init(Plugin *pl)
{
	sendPl = pl;
}
void JuzLog::LogStr(const char *msg,int nGra)
{
	LogFileJuzEvent juzLog;
	juzLog.setMsg((char*)msg,nGra);
	sendPl->sendEvent(&juzLog);
}
void JuzLog::LogA(int nGra,const char *src,...)
{
	char logStr[1024] = {0};
	va_list ap;

	va_start(ap,src);
	vsprintf(logStr,src,ap);

	LogFileJuzEvent juzLog;
	juzLog.setMsg(logStr,nGra);
	sendPl->sendEvent(&juzLog);

	va_end(ap);
}

Juz_Socket_Validation::Juz_Socket_Validation(char what,char type,char arg1,char arg2)
{
	this->what = what;
	this->type = type;
	this->arg1 = arg1;
	this->arg2 = arg2;
}
bool Juz_Socket_Validation::isCmp(char what,char type ,char arg1 ,char arg2)
{
	bool bResult = false;

	if(this->what == what || this->what == 0)
	{
		if(this->type == type || this->type == 0)
		{
			if(this->arg1 == arg1 || this->arg1 == 0)
			{
				if(this->arg2 == arg2 || this->arg2 == 0)
				{
					bResult = true;
				}
			}
		}
	}

	return bResult;
}
JUZ_EPOLL_CLIEN::JUZ_EPOLL_CLIEN()
{
	mIsencrypt = false;
	mPort = 0;
	mCount = 0;
	mpData = NULL;
	memset(mKey,0,sizeof(mKey));
	memset(mIp,0,sizeof(mIp));

	mMutex = new pthread_mutex_t;
	pthread_mutex_init(mMutex, NULL);
}
JUZ_EPOLL_CLIEN::~JUZ_EPOLL_CLIEN()
{
	pthread_mutex_destroy(mMutex);
	delete mMutex;
}
